package cn.s1995.sloth.bizs.constant;

/**
 * SqlCst
 *
 * @Author penf
 * @Description SQL常量
 * @Date 2020/09/02 14:34
 */
public class SqlCst {
    /**
     * limit offset
     */
    private static final String LIMIT_OFFSET = " LIMIT {offset}, {pageSize} ";

    /**
     * limit target
     */
    private static final String LIMIT_TARGET = " LIMIT {target} ";

    /**
     * limit 1
     */
    public static final String LIMIT1 = " LIMIT 1 ";


    /**
     * 获取limit offset
     *
     * @param offset
     * @param pageSize
     * @return
     */
    public static String getLimitOffset(long offset, Long pageSize) {
        String res = LIMIT_OFFSET.replace("{offset}", String.valueOf(offset));
        res = res.replace("{pageSize}", String.valueOf(pageSize != null ? pageSize.longValue() : 10L));
        return res;
    }

    /**
     * 获取limit offset
     *
     * @param target
     * @return
     */
    public static String getLimitTarget(Long target) {
        String res = LIMIT_TARGET.replace("{target}", String.valueOf(target));
        return res;
    }

}
